import React from 'react';
import { inject, observer } from 'mobx-react';
import { Button, Row, Col, Modal } from 'antd';
import { WeaDialog, WeaSearchGroup, WeaFormItem, WeaInput, WeaBrowser, WeaSelect, WeaError } from 'ecCom';
import { toJS } from 'mobx';
import equal from 'deep-equal';
import { WeaLocaleProvider } from 'ecCom';

const getLabel = WeaLocaleProvider.getLabel;

@observer
class changeStatusDialog extends React.Component {
  constructor(props) {
    super(props);
  }


    browserChange =(ids, names, datas) => {
      this.props.contentStore.setCustomerStatus(ids, names);
    }

    render() {
      const { showCustomerStatusModal, showModalStatus, customerStatus, customerStatusSpan } = this.props.contentStore;
      const formItemLayout = {
        labelCol: { span: 6 },
        wrapperCol: { span: 14 },
      };
        // const {replaceDatas} = this.state;
      return (
        <WeaDialog
          ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@wu07rx`}
          title={getLabel(15078, '客户状态')}
          icon="icon-coms-crm"
          iconBgcolor="#96358a"
          visible={showModalStatus}
          style={{ width: 520, height: 200 }}
          buttons={[
            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ohsbma@save`} type="primary" onClick={() => this.doSave()} >{getLabel(86, '保存')}</Button>,
            <Button
              ecId={`${this && this.props && this.props.ecId || ''}_Button@msw8sw@close`}
              onClick={() => {
                showCustomerStatusModal(false);
              }}
            >{getLabel(309, '关闭')}</Button>,
          ]}
          onCancel={() => {
            showCustomerStatusModal(false);
          }}
          hasScroll
        >
          <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@239tum`} needTigger title={getLabel(1361, '基本信息')} showGroup >
            <WeaFormItem
              ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@frzc8h`}
              label={getLabel(15078, '客户状态')}
              {...formItemLayout}
            >
              <WeaError
                ecId={`${this && this.props && this.props.ecId || ''}_WeaError@1w9l25`}
                tipPosition="top"
                ref="weaError"
                error={`"${getLabel(15078, '客户状态')}"${getLabel(21423, '未填写')}`}
              >
                <WeaBrowser
                  ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@1ppgb9`}
                  icon="icon-coms-crm"
                  iconBgcolor="#96358a"
                  inputStyle={{ width: 200 }}
                  type={264}
                  viewAttr={3}
                  replaceDatas={[{ id: customerStatus, name: customerStatusSpan }]}
                  value={customerStatus}
                  title={getLabel(15078, '客户状态')}
                  onChange={(ids, names, datas) => { this.browserChange(ids, names, datas); }}
                />
              </WeaError>
            </WeaFormItem>
          </WeaSearchGroup>
        </WeaDialog>
      );
    }

    doSave=() => {
      const { customerStatus } = this.props.contentStore;
      if (customerStatus == '') {
        this.refs.weaError.showError();
        return;
      }
      this.props.contentStore.batChChangeStatus();
    }
}

export default changeStatusDialog;
